package inode;

import common.Constants;
import common.DFileID;

public class Inode {
	
	public int _size;
	public int _start;
	public int[] _pointers;
	
	public Inode(int start) {
		// get offset from beginning of disk
		_start = start;
		// size of one inode is the number of blocks in a maximum size file
		// plus one block?
		_size = Constants.MAX_FILE_SIZE/Constants.BLOCK_SIZE + Constants.BLOCK_SIZE;
		// one block per pointer
		_pointers  = new int[_size];
		// first block is 1 or 0, depending on whether it's used or not
		_pointers[0] = 0;
		// assign pointers later, give negative value now so we know these blocks aren't yet used
		for (int i = 1; i < _size; i++) {
			_pointers[i] = -1;
		}
	}
	
	public void assignFile(DFileID id) {
		if (_pointers[0]==1) {
			// inode is already in use, throw error?
		}
		for (int i = 1; i < _size; i++) {
			// assign chunks of file to each block
		}
	}

}
